package com.cskaoyan.javase.array;

import java.util.*;

public class Demo62 {
    public static void main(String[] args) {

        //普通员工
        Scanner scan = new Scanner(System.in);
        Employee staffOne = new NormalWorker();
        staffOne.name = scan.nextLine();
        staffOne.jobNumber = scan.nextInt();
        //staffOne.salary=scan.nextFloat();
        System.out.println("----------");
        staffOne.work();
        System.out.println("员工姓名: " + staffOne.name);
        System.out.println("员工工号: " + staffOne.jobNumber);
        System.out.println("员工薪资: " + staffOne.salary);
        scan.close();
        System.out.println("----------");

        //程序员
        Employee staffTwo = new CompProgrammer();
        staffTwo.work();
        System.out.println("员工姓名: " + staffTwo.name);
        System.out.println("员工工号: " + staffTwo.jobNumber);
        System.out.println("员工薪资: " + staffTwo.salary);
        System.out.println("----------");
        //项目经理
        Employee staffThree = new DepManager();
        staffThree.work();
        System.out.println("员工姓名: " + staffThree.name);
        System.out.println("员工工号: " + staffThree.jobNumber);
        System.out.println("员工薪资: " + staffThree.salary);
        System.out.println("----------");


    }
}

//抽象类无法被实例化
abstract class Employee {
    protected String name;//姓名
    protected int jobNumber;//工号
    protected float salary;//工资

/*     怎么把重复的输出也封装到一个方法里面，使得子类可以直接调用？

        protected void printMeg(Object staff){
        System.out.println("员工姓名: "+staff.name);
        System.out.println("员工工号: "+staff.jobNumber);
        System.out.println("员工薪资: "+staff.salary);
    }
*/
    abstract void work();//抽象出一个工作方法，下面根据需求进行重写

    protected Employee() {
    }
}

class NormalWorker extends Employee {//普通员工

    @Override
    protected void work() {
        System.out.println("NormalWorker work");
    }

    protected NormalWorker() {
        this.salary = 4000;
    }
}

class CompProgrammer extends Employee {//程序员

    @Override
    protected void work() {
        System.out.println("CompProgrammer work and overwork");
    }

    protected CompProgrammer() {
        this.salary = 8000;
    }
}

class DepManager extends Employee {//部门经理

    protected float bonus;//奖金

    @Override
    protected void work() {
        System.out.println("DepManager work");
    }

    protected DepManager() {
        this.salary = 10000;
    }
}

